package com.dobbinsoft.iotechn.device.api.open;

import com.dobbinsoft.iotechn.core.annotation.HttpMethod;
import com.dobbinsoft.iotechn.core.annotation.HttpOpenApi;
import com.dobbinsoft.iotechn.core.annotation.HttpParam;
import com.dobbinsoft.iotechn.core.annotation.HttpParamType;
import com.dobbinsoft.iotechn.core.annotation.param.NotNull;
import com.dobbinsoft.iotechn.core.exception.ServiceException;
import com.dobbinsoft.iotechn.device.domain.*;
import com.dobbinsoft.iotechn.device.dto.ControllerComponentDTO;

import java.util.List;
import java.util.Map;

/**
 * Description:
 * User: rize
 * Date: 2020/6/18
 * Time: 16:37
 */
@HttpOpenApi(group = "controller.dev", description = "开发者遥控器服务")
public interface ControllerDevService {

    /**
     * 产品下遥控器列表
     * @param productId
     * @param developerId
     * @return
     * @throws ServiceException
     */
    @HttpMethod(description = "列表")
    public List<ProductControllerDO> list(
            @NotNull @HttpParam(name = "productId", type = HttpParamType.COMMON, description = "产品Id") Long productId,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    /**
     * 产品下创建遥控器
     * @param title
     * @param description
     * @param productId
     * @param developerId
     * @return
     * @throws ServiceException
     */
    @HttpMethod(description = "创建")
    public String create(
            @NotNull @HttpParam(name = "title", type = HttpParamType.COMMON, description = "标题") String title,
            @HttpParam(name = "description", type = HttpParamType.COMMON, description = "描述") String description,
            @NotNull @HttpParam(name = "productId", type = HttpParamType.COMMON, description = "产品Id") Long productId,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    /**
     * 获取遥控器下所有组件
     * @param controllerId
     * @param developerId
     * @return
     * @throws ServiceException
     */
    @HttpMethod(description = "列举遥控器组件")
    public List<ControllerComponentDTO> listComponent(
            @NotNull @HttpParam(name = "controllerId", type = HttpParamType.COMMON, description = "遥控器Id") Long controllerId,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    @HttpMethod(description = "遥控器下创建组件")
    public String createComponent(
            @NotNull @HttpParam(name = "controllerId", type = HttpParamType.COMMON, description = "遥控器Id") Long controllerId,
            @NotNull @HttpParam(name = "componentLibId", type = HttpParamType.COMMON, description = "组件库Id") Long componentLibId,
            @NotNull @HttpParam(name = "styleMode", type = HttpParamType.COMMON, description = "样式模式，前端解释") Integer styleMode,
            @HttpParam(name = "style", type = HttpParamType.COMMON, description = "样式") String style,
            @HttpParam(name = "title", type = HttpParamType.COMMON, description = "标题", valueDef = "未命名组件") String title,
            @HttpParam(name = "sort", type = HttpParamType.COMMON, description = "排序", valueDef = "0") Integer sort,
            @HttpParam(name = "attrList", type = HttpParamType.COMMON, description = "属性JSON", valueDef = "[]") String attrListStr,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    @HttpMethod(description = "遥控器下创建组件")
    public String editComponent(
            @NotNull @HttpParam(name = "componentId", type = HttpParamType.COMMON, description = "组件Id") Long componentId,
            @NotNull @HttpParam(name = "styleMode", type = HttpParamType.COMMON, description = "样式模式，前端解释") Integer styleMode,
            @HttpParam(name = "style", type = HttpParamType.COMMON, description = "样式") String style,
            @HttpParam(name = "title", type = HttpParamType.COMMON, description = "标题", valueDef = "未命名组件") String title,
            @HttpParam(name = "sort", type = HttpParamType.COMMON, description = "排序", valueDef = "0") Integer sort,
            @HttpParam(name = "attrList", type = HttpParamType.COMMON, description = "属性JSON", valueDef = "[]") String attrListStr,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    @HttpMethod(description = "删除组件")
    public String deleteComponent(
            @NotNull @HttpParam(name = "componentId", type = HttpParamType.COMMON, description = "组件Id") Long componentId,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    @HttpMethod(description = "调整组件顺序")
    public String adjustSort(
            @NotNull @HttpParam(name = "sortMap", type = HttpParamType.COMMON, description = "顺序映射") String sortMapStr,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    @HttpMethod(description = "列举组件属性")
    public List<ControllerComponentAttrDO> listComponentAttr(
            @NotNull @HttpParam(name = "componentId", type = HttpParamType.COMMON, description = "组件Id") Long componentId,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;



    /**** 组件库操作 ****/
    @HttpMethod(description = "获取库")
    public List<ControllerComponentLibDO> listLib(
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;

    @HttpMethod(description = "获取库属性")
    public List<ControllerComponentLibAttrDO> listLibAttr(
            @NotNull @HttpParam(name = "libId", type = HttpParamType.COMMON, description = "库组件Id") Long libId,
            @NotNull @HttpParam(name = "developerId", type = HttpParamType.DEVELOPER_ID, description = "开发者Id") Long developerId) throws ServiceException;


}
